import request from "@/utils/request";


// 添加部门
export function addDept(data: any) {
  return request({
    url: "/Dept/Add",
    method: "POST",
    data
  });
}
// 新增获取部门树接口
export function getDeptTree() {
  return request({
    url: "/Dept/GetDeptTree",
    method: "GET"
  });
}
// 更新部门
export function updateDept(data: any) {
  return request({
    url: "/Dept/Update",
    method: "PUT",
    data
  });
}

// 删除部门
export function deleteDept(id: string) {
  return request({
    url: `/Dept/Delete/${id}`,
    method: "DELETE"
  });
}

// 获取部门详情
export function getDeptById(id: string) {
  return request({
    url: `/Dept/GetById/${id}`,
    method: "GET"
  });
}

// 获取所有部门
export function getDeptList() {
  return request({
    url: "/Dept/GetAll",
    method: "GET"
  });
}

// 检查部门名称是否存在
export function isDeptExists(name: string) {
  return request({
    url: `/Dept/IsDeptExists?name=${name}`,
    method: "GET"
  });
}

// 更新部门名称
export function updateDeptName(deptId: string, newName: string) {
  return request({
    url: `/Dept/UpdateDeptName/${deptId}`,
    method: "POST",
    data: { newName }
  });
}